
// T3_EditorView.h : interface of the CT3_EditorView class
//


#pragma once

enum EditorState
{
	EDITOR_STATE_NOT_INIT,
	EDITOR_STATE_INIT,
};

enum EditorModeEnum
{
	EDITOR_MODE_TILE_ADD,
	EDITOR_MODE_TILE_REMOVE,
};

class CT3_EditorView : public CView
{
protected: // create from serialization only
	CT3_EditorView();
	DECLARE_DYNCREATE(CT3_EditorView)

// Attributes
public:
	CT3_EditorDoc* GetDocument() const;

// Operations
public:

// Overrides
public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void OnInitialUpdate();
protected:
	void OnSize(UINT nType, int cx, int cy);
// Implementation
public:
	virtual ~CT3_EditorView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif
	
protected:
	void ResetRenderWindow();
	Ray CastRayAtCursorPoint(const CPoint& point) const;
	void NotifyRedrawEvent();

protected:
	GW_RENDER_WINDOW*	m_RenderWindow;
	EditorState			m_State;
	FreeFlyCamera		m_Camera;

private:
	CPoint				m_CursorPoint;
	Vector3				m_CamMovementVector;
	StageGeom*			m_PickingStageGeom;
	CPoint				m_RMBDownPoint;
	bool				m_IsRMBDown;
	bool				m_NeedRedrawView;

	EditorModeEnum		m_EditorMode;

// Generated message map functions
protected:
	afx_msg void OnFilePrintPreview();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

	void AddTileAtCursor();
	void RemoveTileAtCursor();

	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpcs);
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTileAddMode();
	afx_msg void OnUpdateTileAddMode(CCmdUI *pCmdUI);
	afx_msg void OnTileRemoveMode();
	afx_msg void OnUpdateTileRemoveMode(CCmdUI *pCmdUI);
};

#ifndef _DEBUG  // debug version in T3_EditorView.cpp
inline CT3_EditorDoc* CT3_EditorView::GetDocument() const
   { return reinterpret_cast<CT3_EditorDoc*>(m_pDocument); }
#endif

